#!/usr/bin/env bash
# -*- encoding UTF-8 -*-
# Author: kjzhu

export PGRDIR=$(cd `dirname $0`; pwd)
export WORKSPACE=${PGRDIR}/../../
export VERSION=$1

source ${PGRDIR}/env.sh

# only set VERSION if not set
: ${VERSION:="latest"}

# break shell when fail
set -e


docker build -t ${DOCKER_REGISTRY_URL}/${DOCKER_IMAGE_NAME}:${VERSION} --force-rm -f ${PGRDIR}/Dockerfile ${WORKSPACE}
docker push ${DOCKER_REGISTRY_URL}/${DOCKER_IMAGE_NAME}:${VERSION}
